package cn.t235.util;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author 天天向上 （john.yi@qq.com）
 * @date 2020/10/20.
 */
public class MyBatisUtil {
    private static SqlSessionFactory sf;

    static {
        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        try {
            sf = builder.build(Resources.getResourceAsReader("mybatis-config.xml"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static SqlSession createSession() {
        return sf.openSession();
    }

    public static void main(String[] args) throws IOException, SQLException {

    }
}
